/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bean;

import java.sql.*;
import oracle.jdbc.pool.OracleDataSource;

public class koneksi {

    private String nama ;
    private String alamat ;
    private String asalsekolah ;
    private String tanggallahir ;
    private String jeniskelamin ;
    private String agama ;
    private String nis ;
    private String nem ;
    
    
    private static Connection conn;

// Sesuaikan properti jdbcURL dengan basis data anda
//
//    private String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:xe";
//    String userid = "system";
////    String password = "hr";
//    private String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:xe";
//    String userid = "youland";
//    String password = "youland";
//    
    private String jdbcUrl = "jdbc:Oracle:thin:@172.23.9.185:1521:orcl";
    String userid = "MHS105314029";
    String password = "MHS105314029";
    
    /** Creates a new instance of UserConnection */
    public koneksi() {
        try {
            OracleDataSource ds;
            ds = new OracleDataSource();
            ds.setURL(jdbcUrl);
            conn = ds.getConnection(userid, password);
            System.out.println("Koneksi berhasil");
        } catch (SQLException ex) {
            System.out.println("Masih belum koneksi");
        }
    }

    public koneksi(String nama, String alamat, String asalsekolah, String tanggallahir, String jeniskelamin, 
            String agama, String nis, String nem){
        this.nama = nama;
        this.alamat = alamat;
        this.asalsekolah = asalsekolah;
        this.tanggallahir = tanggallahir;
        this.jeniskelamin = jeniskelamin;
        this.agama = agama;
        this.nis = nis;
        this.nem = nem;
        
    }

    public boolean isConnected(){
        if (conn!=null) {
            return true;
        }
        else {
            return false;
        }
    }
    public boolean getClosed(){
        if(isConnected()){
            try {
                conn.close();
                conn=null;
            } catch (SQLException ex) {
            }
            return true;
        } else {
            return false;
        }
    }

    public String getJdbcUrl() {
        return jdbcUrl;
    }

    public void setJdbcUrl(String jdbcUrl) {
        this.jdbcUrl = jdbcUrl;
    }   

    public Connection getConnection() {
        return conn;
    }

    public void setConn(Connection connection) {
        koneksi.conn = connection;
    }

    public static void main(String args[]){
        koneksi conn = new koneksi();

        try{
            String query="select * from pendaftaran";
            Statement statement = conn.getConnection().createStatement();
            ResultSet result = statement.executeQuery(query);

            
            statement.close();
        } catch(Exception ex){
            System.out.println("message: "+ex.getMessage());
        }

    }

    /**
     * @return the nama
     */
    public String getNama() {
        return nama;
    }

    /**
     * @param nama the nama to set
     */
    public void setNama(String nama) {
        this.nama = nama;
    }

    
    /**
     * @return the alamat
     */
    public String getAlamat() {
        return alamat;
    }

    /**
     * @param alamat the alamat to set
     */
    public void setAlamat(String alamat) {
        this.alamat = alamat;
    }

    /**
     * @return the asalsekolah
     */
    public String getAsalsekolah() {
        return asalsekolah;
    }

    /**
     * @param asalsekolah the asalsekolah to set
     */
    public void setAsalsekolah(String asalsekolah) {
        this.asalsekolah = asalsekolah;
    }

    /**
     * @return the tanggallahir
     */
    public String getTanggallahir() {
        return tanggallahir;
    }

    /**
     * @param tanggallahir the tanggallahir to set
     */
    public void setTanggallahir(String tanggallahir) {
        this.tanggallahir = tanggallahir;
    }

    /**
     * @return the jeniskelamin
     */
    public String getJeniskelamin() {
        return jeniskelamin;
    }

    /**
     * @param jeniskelamin the jeniskelamin to set
     */
    public void setJeniskelamin(String jeniskelamin) {
        this.jeniskelamin = jeniskelamin;
    }

    /**
     * @return the agama
     */
    public String getAgama() {
        return agama;
    }

    /**
     * @param agama the agama to set
     */
    public void setAgama(String agama) {
        this.agama = agama;
    }

    /**
     * @return the nis
     */
    public String getNis() {
        return nis;
    }

    /**
     * @param nis the nis to set
     */
    public void setNis(String nis) {
        this.nis = nis;
    }

    /**
     * @return the nem
     */
    public String getNem() {
        return nem;
    }

    /**
     * @param nem the nem to set
     */
    public void setNem(String nem) {
        this.nem = nem;
    }

    /**
     * @return the notlp
     */
    

}



